{% extends "layout.html" %}
{% block content %}

<div class="row-fluid" style="margin-top: 20px;">
  <div class="span4">
    <div class="widget">
      <div class="widget-header">
        <h3><span class="badge badge-success">{{ active_orders | count | default(0) }}</span> Orders in progress</h3>
      </div>
      <div class="widget-content">
        <div class="widget-nomargin">
          {% if active_orders %}
            <table class="hirein-widget-full-table">
              <thead>
              <th>#</th>
              <th>Food</th>
              <th>Quantity</th>
              <th>&nbsp;</th>
              </thead>
              <tbody>
                {% for order in active_orders %}
                <tr>
                  <td>{{ order.id }}</td>
                  <td>{{ order.menu_item.food.name }}</td>
                  <td>{{ order.quantity }}</td>
                  <td>
                    <a href="{{ url_for('mark_order_ready', order_id=order.id) }}" class="btn btn-primary pull-right">Ready</a>
                  </td>
                </tr>
                {% endfor %}
              </tbody>
            </table>
          {% else %}
            <p style="padding:15px 10px;">There are no active orders. Try refreshing the page frequently.</p>
          {% endif %}
        </div>
      </div>
    </div>
  </div>
  <div class="span4">
    <div class="widget">
      <div class="widget-header">
        <h3><span class="badge badge-success">{{ ready_orders | count | default(0) }}</span> Ready to pick up</h3>
      </div>
        <div class="widget-content">
            <div class="widget-nomargin">
              {% if ready_orders %}
                <table class="hirein-widget-full-table">
                    <thead>
                    <th>#</th>
                    <th>Food</th>
                    <th>Quantity</th>
                    <th>&nbsp;</th>
                    </thead>
                    <tbody>
                    {% for order in ready_orders %}
                    <tr>
                        <td>{{ order.id }}</td>
                        <td>{{ order.menu_item.food.name }}</td>
                        <td>{{ order.quantity }}</td>
                        <td>
                            <a href="{{ url_for('mark_order_completed', order_id=order.id) }}" class="btn btn-primary pull-right">Picked Up</a>
                        </td>
                    </tr>
                    {% endfor %}
                    </tbody>
                </table>
              {% else %}
                <p style="padding: 15px 10px;">There are no orders ready for pick up. You should work faster!</p>
              {% endif %}
            </div>
        </div>
    </div>
  </div>
  <div class="span4">
    <div class="widget">
      <div class="widget-header">
        <h3><span class="badge badge-success">{{ completed_orders | count | default(0) }}</span> Orders completed</h3>
      </div>
        <div class="widget-content">
            <div class="widget-nomargin">
              {% if completed_orders %}
                <table class="hirein-widget-full-table">
                    <thead>
                    <th>#</th>
                    <th>Food</th>
                    </thead>
                    <tbody>
                    {% for order in completed_orders %}
                    <tr>
                        <td>{{ order.id }}</td>
                        <td>{{ order.menu_item.food.name }}</td>
                    </tr>
                    {% endfor %}
                    </tbody>
                </table>
              {% else %}
              <p style="padding: 15px 10px;">No orders completed.</p>
              {% endif %}
            </div>
        </div>
    </div>
  </div>
</div>
{% endblock %}